﻿using System.Collections.Generic;

namespace Utilitys
{
    public class ObjectPool<T> where T : new()
    {
        private static readonly Queue<T> Objects = new Queue<T>();

        public static T Get()
        {
            if (Objects.Count > 0)
                return Objects.Dequeue();
            var o = new T();
            return o;
        }

        public static void Release(T o)
        {
            Objects.Enqueue(o);
        }
    }
}